export interface ProblemSet {
  id: number;
  title: string;
  description: string;
  content: string;
  creator: number;
  creator_name: string;
  team: number | null;
  team_name: string | null;
  visibility: 'public' | 'team';
  is_active: boolean;
  problem_count: number;
  created_time: string;
}

export interface ProblemSetProblem {
  id: number;
  problem: {
    id: number;
    _id: string;
    title: string;
    difficulty: 'Low' | 'Mid' | 'High';
    time_limit: number;
    memory_limit: number;
    submission_number: number;
    accepted_number: number;
  };
  order: number;
  added_time: string;
  user_status?: boolean | null;  // true: 通过, false: 未通过, null: 未答题
}

export interface CreateProblemSetRequest {
  title: string;
  description: string;
  content: string;
  team?: number;
  visibility: 'public' | 'team';
}

export interface UpdateProblemSetRequest {
  title?: string;
  description?: string;
  content?: string;
  team?: number;
  visibility?: 'public' | 'team';
  is_active?: boolean;
}

export interface AddProblemRequest {
  problem_id: string;
}

export interface RemoveProblemRequest {
  problem_id: string;
}

export interface UpdateProblemOrderRequest {
  problem_id: string;
  order: number;
}

export interface ProblemSetListParams {
  page?: number;
  limit?: number;
  visibility?: 'public' | 'team';
  team_id?: number;
  title?: string;
}

export interface ProblemSetListResponse {
  count: number;
  next: string | null;
  previous: string | null;
  results: ProblemSet[];
}

// 排行榜相关类型定义
export interface LeaderboardUser {
  id: number;
  username: string;
  real_name: string;
  avatar: string;
}

export interface ProblemStatus {
  status: 'accepted' | 'attempted' | 'not_attempted';
  first_ac_time?: string;
  submission_count: number;
}

export interface LeaderboardEntry {
  rank: number;
  user: LeaderboardUser;
  solved_count: number;
  first_ac_time: string;
  problem_status: Record<string, ProblemStatus>;
}

export interface LeaderboardProblem {
  id: string;
  title: string;
  difficulty: 'Low' | 'Mid' | 'High';
}

export interface LeaderboardData {
  problem_set: {
    id: number;
    title: string;
    team: {
      id: number;
      name: string;
    };
  };
  problems: LeaderboardProblem[];
  leaderboard: LeaderboardEntry[];
} 